package flex.persistence {
	import mx.core.mx_internal;
	import flex.persistence.exceptions.PersistenceException;
	
	
	use namespace mx_internal;
	
	public class EntityManagerFactory {
		
		// Liste des differents entityManager
		[ArrayElementType("flex.persistence.EntityManager")] 
		mx_internal static var entityManagers:Object = {}; 
		
		/**
		 * Récupere l'entityManager pour un nom donnée
		 */
		public static function createEntityManager(unitName:String="default"):EntityManager {
			if(!unitName) unitName = "default";
			if(!entityManagers[unitName]) throw new PersistenceException("Unkonwn unitName : "+unitName);
			return entityManagers[unitName];
		}
	}
}